#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


int main()
{

	int sock = 0;
	int ret = 0;
	char buf[1024] = {0};

	struct sockaddr_in addr;
    memset(&addr,0,sizeof(addr));

	sock = socket(AF_INET,SOCK_DGRAM,0);
	if(sock == -1)
	{
		perror("sock");
		exit(-1);
	}

	addr.sin_family = AF_INET;
    addr.sin_port = 6868;
    addr.sin_addr.s_addr = inet_addr("192.168.0.116");

	ret = bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr));
	if(ret == -1)
	{
		perror("bind");
		exit(-1);
	}

while(1)
{
	ret = recvfrom(sock,buf,1024,0,NULL,NULL);
	if(ret == -1)
	{
		perror("recvfrom");
		exit(-1);
	}

	printf("buf is %s\n",buf);
}

	close(sock);


}
